package com.oocl.bookbuilder;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.io.Writer;

import com.fasterxml.jackson.databind.ObjectMapper;

import random.RandomBuilderImpl;

public class Run {
	public void run(int n,String filename) throws IOException{
//		OutputStream out = new FileOutputStream(filename,true);
		FileWriter fw = new FileWriter(filename);
		ObjectMapper mapper = new ObjectMapper();
		RandomBuilderImpl rb = new RandomBuilderImpl();
		String ostr ;
		for (int i = 0; i < n; i++) {
			ostr=mapper.writeValueAsString(rb.randomBuild());
			fw.write(ostr+"\n");
		}
		fw.close();
	}
	public static void main(String[] args) throws IOException {
		new Run().run(10000, "json.txt");	
//		InputStream in = new FileInputStream("json.txt");
//		BufferedReader reader = new BufferedReader(new InputStreamReader(in));  
//		int sum =0;
//		String stri ;
//		while((stri=reader.readLine())!=null){
//			sum++;
//			System.out.println(stri);
//		}
//		
//		System.out.println(sum);
//		reader.close();
	}
}


